package com.ctshk.rpc.finance.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ctshk.rpc.finance.base.CustomBaseMapper;
import com.ctshk.rpc.finance.dto.stamptax.StampTaxRefundListDTO;
import com.ctshk.rpc.finance.entity.FinanceStampTaxRefund;
import com.ctshk.rpc.finance.req.stamptax.StampTaxRefundListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 印花税退款记录 Mapper 接口
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-05
 */
public interface FinanceStampTaxRefundMapper extends CustomBaseMapper<FinanceStampTaxRefund> {

    /**
     * 列表
     * @param iPage
     * @param req
     * @return
     */
    @Select("<script>SELECT a.*\n" +
            "FROM t_finance_stamp_tax_refund a\n" +
            "WHERE a.is_deleted = 0\n" +
            "<if test=\"req.refundNumber != null\">AND a.refund_number LIKE CONCAT('%',#{req.refundNumber},'%')</if> \n" +
            "<if test=\"req.productNumber != null\">AND a.product_number LIKE CONCAT('%',#{req.productNumber},'%')</if> \n" +
            "<if test=\"req.businessType != null\">AND a.business_type = #{req.businessType}</if> \n" +
            "<if test=\"req.cancelTimeBegin != null and req.cancelTimeEnd != null\">AND a.cancel_time BETWEEN #{req.cancelTimeBegin} AND #{req.cancelTimeEnd}</if> \n" +
            "<if test=\"req.departmentId != null\">AND a.department_id = #{req.departmentId}</if> \n" +
            "<if test=\"req.saleUserId != null\">AND a.sale_user_id = #{req.saleUserId}</if> \n" +
            "<if test=\"req.refundStatus != null\">AND a.refund_status = #{req.refundStatus}</if> \n" +
            "<if test=\"req.exportStatus != null\">AND a.export_status = #{req.exportStatus}</if> \n" +
            "ORDER BY a.gmt_create DESC</script>")
    Page<StampTaxRefundListDTO> queryListByCondition(@Param("iPage") Page<StampTaxRefundListDTO> iPage, @Param("req") StampTaxRefundListReq req);
}
